package org.nvframe.component.property;
import java.util.HashMap;
import java.util.Map;

import org.nvframe.component.AbstractComponent;
import org.nvframe.entity.Entity;
import org.nvframe.util.Settings;

/**
 * PropertyManager is a collector for transient properties 
 * like health, damageresistance, armor, ...
 * 
 * @author Nik Van Looy
 *
 */
public class PropertyManager extends AbstractComponent {
	
	private Map<String, TransientProperty> properties;
	
	public PropertyManager(String id, Entity owner, Settings settings) {
		super(id, owner);
		properties = new HashMap<String, TransientProperty> ();
	}
	
	/**
	 * set a property with specified id to an integer value
	 * 
	 * @param propId The property name
	 * @param val The property value
	 */
	public void setProperty(String propId, int val) {
		properties.put(propId, new TransientPropertyInt(val));
	}
	public void setProperty(String propId, float val) {
		properties.put(propId, new TransientPropertyFloat(val));
	}
	/*public void setProperty(String propId, double val) {
		properties.put(propId, new TransientPropertyDouble(val));
	}*/
	
	/**
	 * get the transient value of an integer property
	 * 
	 * @param propId the property name
	 * @return The transient value
	 */
	public int getValueInt(String propId) {
		return ((TransientPropertyInt) properties.get(propId)).getValue();
	}
	public float getValueFloat(String propId) {
		return ((TransientPropertyFloat) properties.get(propId)).getValue();
	}
	/*public double getValueDouble(String propId) {
		return ((TransientPropertyDouble) properties.get(propId)).getValue();
	}*/
	
	/**
	 * get the persistent (original) value of an integer property
	 * 
	 * @param propId The property name
	 * @return The persistent value
	 */
	public int getPropertyPersistentInt(String propId) {
		return ((TransientPropertyInt) properties.get(propId)).getPersistentVal();
	}
	public float getPropertyPersistentFloat(String propId) {
		return ((TransientPropertyFloat) properties.get(propId)).getPersistentVal();
	}
	/*public double getPropertyPersistentDouble(String propId) {
		return ((TransientPropertyDouble) properties.get(propId)).getPersistentVal();
	}*/
	

	public TransientPropertyInt getPropertyInt(String propId) {
		return (TransientPropertyInt) properties.get(propId);
	}
	public TransientPropertyFloat getPropertyFloat(String propId) {
		return (TransientPropertyFloat) properties.get(propId);
	}
	/*public TransientPropertyDouble getPropertyDouble(String propId) {
		return (TransientPropertyDouble) properties.get(propId);
	}*/
	

}
